package com.shui_shui;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.shui_shui.db.myDB;
import com.shui_shui.detailview.DetailView;

public class Guide extends Activity implements OnTouchListener {

	private DetailView guide;
	final myDB myDb = new myDB(this);
	private String[] data;
	private TextView topic;
	private TextView detail;
	private ImageView back;
	private ImageView help;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guidedetail);
		
		back = (ImageView) findViewById(R.id.back);
		help = (ImageView) findViewById(R.id.help);
		
		back.setOnTouchListener(this);
		help.setOnTouchListener(this);
		
		guide = DetailView.getView();
		int id = guide.getIdView();
		data = myDb.selectDATABASE_GUIDE_TABLE(id);
		
		topic = (TextView) findViewById(R.id.textView1);
		detail = (TextView) findViewById(R.id.guideTextView1);
		
		topic.setText(data[1]);
		detail.setText(data[2]);
	}
	
	@SuppressWarnings("deprecation")
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.back:
			switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				back.setAlpha(150);
				break;
			case MotionEvent.ACTION_UP:
				back.setAlpha(255);
				this.finish();
				break;
			default:
				break;
			}
			break;
		case R.id.help:
			switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				help.setAlpha(150);
				break;
			case MotionEvent.ACTION_UP:
				help.setAlpha(255);
				break;
			default:
				break;
			}
			break;
		}
		return true;
	}
	
}
